/**
 * 203. 移除链表元素
 */
public class No203 {
    public ListNode removeElements(ListNode head, int val) {
        ListNode sent = new ListNode(-1, head);
        ListNode cur = sent;
        while (cur != null && cur.next != null) {
            while (cur.next != null && cur.next.val == val) {
                cur.next = cur.next.next;
            }
            cur = cur.next;
        }
        return sent.next;
    }
}
